<?php
/**
 * Created by PhpStorm.
 * User: xiaomeng
 * Date: 17-9-22
 * Time: 上午9:47
 */
namespace swf\socket;

use swf\core\syncDb;

class LimitBet
{

    /**
     * 限制投注
     * @param $betting_num
     * @param $amount
     * @return bool
     */
    static public function upperLimit($betting_num,$amount)
    {
        //上限列表
        $limit_bet = syncDb::redis()->get("limit_bet");
        $limit_bet = json_decode($limit_bet,true);
        //投注列表
        $bet_list = syncDb::redis()->get("bet_list");
        $bet_list = json_decode($bet_list,true);
        $_bet_list = @array_column($bet_list,$betting_num);
        $_bet_sum = @array_sum($_bet_list);
        $_bet_sum += $amount;

        if($limit_bet[$betting_num] < $_bet_sum)
        {
            return false;
        }
        return true;

    }
}